import { createRouter, createWebHistory } from "vue-router";
import TaskManager from "@/components/TaskManager.vue";
import TodayTasks from "@/components/TodayTasks.vue";
import TaskInfo from "@/components/TaskInfo.vue";
import TaskStatistics from "@/components/TaskStatistics.vue";
import UserProfile from "@/components/UserProfile.vue";

const routes = [
  {
    path: '/',
    component: TaskManager,
    children: [
      {
        path: '',
        name: 'TodayTasks',
        component: TodayTasks,
        children: [
          {
            path: 'task/:task',
            name: 'TaskInfo',
            component: TaskInfo,
            props: (route) => ({
              task: JSON.parse(route.params.task)
            })
          }
        ]
      },
      {
        path: 'statistics',
        name: 'TaskStatistics',
        component: TaskStatistics
      },
      {
        path: 'profile',
        name: 'UserProfile',
        component: UserProfile
      }
    ]
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

export default router;